import request from '@/utils/request'
/**
 * 登陆
 * @param {String} account - 帐号
 * @param {String} password - 密码
 * @returns
 */
export const userLogin = ({ account, password }) => {
  return request('/api/login', 'post', { account, password })
}

/**
 * 注册
 * @param {String} account - 帐号
 * @param {String} password - 密码
 * @returns
 */
export const userReg = ({ account, password }) => {
  return request('/api/register', 'post', { account, password })
}

/**
 * 获取用户资料
 * @param {number} uid -用户ID
 * @returns
 */
export const getUserInfo = ({ uid }) => {
  return request('/user/center', 'get', { uid })
}

/**
 * 修改用户信息
 * @param {*}
 * @returns
 */
export const updateUserInfo = ({ account, phone, oldPwd, newPwd, uid }) => {
  return request('/user/update/userInfo', 'post', { account, phone, oldPwd, newPwd, uid })
}

/**
 * 获取用户下单地址
 * @param {number} uid -用户ID
 * @returns
 */
export const getUserAddress = ({ uid }) => {
  return request('/user/address', 'get', { uid })
}

/**
 * 修改下单地址
 * @param {*} param
 * @returns
 */
export const updateAddress = ({ name, tel, site, uid }) => {
  return request('/user/address/update', 'post', { name, tel, site, uid })
}

/**
 * 添加下单地址
 * @param {*} param
 * @returns
 */
export const insertAddress = ({ name, tel, site, uid, remarks }) => {
  return request('/user/address/insert', 'post', { name, tel, site, uid, remarks })
}
